package com.ysg.utils;

import android.app.ActivityManager;
import android.content.Context;
import java.util.List;

public class YServiceUtil {

    /**
     * 判断服务是否在运行
     */
    public static boolean isRunning(Context mContext, String className){
        boolean isRunning = false ;
        ActivityManager activityManager = (ActivityManager)   mContext.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningServiceInfo> services = activityManager.getRunningServices(1000);
        if (YCollectionUtil.isEmpty(services)){
            return false;
        }
        for (int i=0 ;i < services.size();i++){
            if (YStringUtil.eq(services.get(i).service.getClassName(), className)){
                isRunning = true;
                break;
            }
        }
        return  isRunning;
    }


}
